﻿<%@ Page Title="编辑新闻" Language="C#" MasterPageFile="~/Areas/Manage/Views/Shared/Master.Master"
    Inherits="System.Web.Mvc.ViewPage<ENews>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <% using (Html.BeginForm())
       {%>
    <table class="table">
        <tr>
            <td>
                标 题<%=Html.Hidden("newsId", Model.NewsId)%>
            </td>
            <td>
                <%=Html.TextBox("title", Model.Title, new { @class="width300" })%>
            </td>
            <td>
                封面图片(宽200像素 * 高150像素)
            </td>
        </tr>
        <tr>
            <td>
                作 者
            </td>
            <td>
                <%=Html.TextBox("author", Model.Author)%>
            </td>
            <td rowspan="4">
                <img id="cover" src="<%=Model.ImageName %>" alt="" title="点击设置封面" />
                <%= Html.Hidden("ImageName",Model.ImageName) %>
            </td>
        </tr>
        <tr>
            <td>
                类 别
            </td>
            <td>
                <%=Html.DropDownList("classifyId",new SelectList(ViewData["classifyList"] as List<SelectListItem>,"Value","Text",Model.ClassifyId))%>
            </td>
        </tr>
        <tr>
            <td>
                排 序
            </td>
            <td>
                <%=Html.TextBox("sortId", Model.SortId)%>
            </td>
        </tr>
        <tr>
            <td>
                有效性
            </td>
            <td>
                <%=Html.CheckBox("isvalid", Model.Isvalid)%>
            </td>
        </tr>
        <tr>
            <td>
                内 容
            </td>
            <td colspan="2">
                <%=Html.TextArea("contents", Model.Contents)%>
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td colspan="2">
                <input type="submit" id="submit" name="submit" value="提 交" />
                <input type="reset" id="reset" name="reset" value="重 置" />
            </td>
        </tr>
    </table>
    <%}
    %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cssLink" runat="server">
    <style type="text/css">
        #cover
        {
            width: 200px;
            height: 150px;
            cursor:pointer;
        }
    </style>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="jsLink" runat="server">
    <script src="<%=Url.Content("~/WebResources/ckeditor/ckeditor.js")%>" type="text/javascript"></script>
    <script type="text/javascript" src="<%=Url.Content("~/WebResources/ckfinder/ckfinder.js") %>"></script>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="cssContent" runat="server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="jsContent" runat="server">
    <script type="text/javascript">
        var ShowFileManage = function () {
            var ckfinder = new CKFinder(null, null, 500, "SetUrl");
            var dialog = $("<div title='文件浏览器'></div>")
            dialog.append(ckfinder.CreateHtml());
            dialog.dialog(
            { modal: true
            , width: 800
            , close: function () { $(this).dialog("destory"); dialog.remove(); }
            , closeText: "×"
            });

            window["dialog"] = dialog;

        };
        $(function () {
            CKEDITOR.replace("contents", { height: "300px" });
            $(':form').ajaxForm(function (msg) {
                eval(msg);
            });

            $("#cover").click(function () {
                var _cover = $(this);
                //插入回调
                window["SetUrl"] = function (filePath) {
                    _cover.parent().find(":hidden['ImageName']").val(filePath);
                    _cover.attr("src", filePath);
                    window["dialog"].dialog("close");
                }
                ShowFileManage();
            });
        });
    </script>
</asp:Content>
